package com.teach.controller;

import com.teach.pojo.RespBean;
import com.teach.service.CourseService;
import com.teach.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CourseController {
    @Autowired
    private CourseService courseService;
    @Autowired
    private ScoreService scoreService;

    @GetMapping("/getCourses")
    public RespBean getCourses(Long classId) {
        return RespBean.success(courseService.getCoursesByClass(classId));
    }

    @GetMapping("/getUserByClassAndCourse")
    public RespBean getUserByClassAndCourse(Long classId,Long courseId) {
        return RespBean.success(courseService.getUserByClassAndCourse(classId,courseId));
    }

    @GetMapping("/updateScore")
    public RespBean updateScore(Long userId,Long courseId, Integer num) {
        scoreService.updateScore(userId,courseId,num);
        return RespBean.success("修改成功");
    }


}
